---
description: "Reference for Nitric's v0 JVM library - Creates a new Schedule to run a function on a defined frequency."
---

# JVM - schedule()

Creates a new Schedule to run a function on a defined frequency.

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.faas.v0.Frequency;

public class Application {
  public static void main(String[] args) {
    Nitric.INSTANCE.schedule("aggregate-data").every(3, Frequency.Hours, (ctx) -> {
      System.out.println("aggregating data");
      return ctx;
    });

    Nitric.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.faas.v0.Frequency

fun main() {
  Nitric.schedule("aggregate-data").every(3, Frequency.Hours) { ctx ->
    println("aggregating data")
    ctx
  }

  Nitric.run()
}
```

</TabItem>

</Tabs>

## Parameters

<Properties>
  <Property name="description" required type="String">
    The unique name of this Schedule within the app. Subsequent calls to
    `schedule` with the same name will return the same object.
  </Property>
</Properties>

### Notes

- Schedules do not require access permissions to be specified.
- During local development schedules can be triggered manually from the local development dashboard

## Examples

### Create a Schedule

<Tabs syncKey="jvm-lang">

<TabItem label="Java">

```java
import io.nitric.Nitric;
import io.nitric.faas.v0.Frequency;

public class Application {
  public static void main(String[] args) {
    // Can be defined as a rate using `.every()`
    Nitric.INSTANCE.schedule("send-reminders").every(3, Frequency.Minutes, (ctx) -> {
      // add code to run here
      return ctx;
    });

    // Can be defined as a cron expression using `.cron()`
    Nitric.INSTANCE.schedule("archive-orders").cron("0 1 1 * *", (ctx) -> {
      // add code to run here
      return ctx;
    });

    Nitric.run();
  }
}
```

</TabItem>

<TabItem label="Kotlin">

```kotlin
import io.nitric.Nitric
import io.nitric.faas.v0.Frequency

fun main() {
  // Can be defined as a rate using `.every()`
  Nitric.schedule("send-reminders").every(3, Frequency.Minutes) { ctx ->
    // add code to run here
    ctx
  }

  // Can be defined as a cron expression using `.cron()`
  Nitric.schedule("archive-orders").cron("0 1 1 * *") { ctx ->
    // add code to run here
    ctx
  }

  Nitric.run()
}
```

</TabItem>

</Tabs>
